import Vue from 'vue'
import X from 'vuex'
import App from './App.vue'

Vue.use(X)

const store = new X.Store({
  'state': {
    'count': 0,
  },
  'mutations': {
    'increment' (state) {
      state.count++
    },
  },
  'actions': {
    'increment' ({commit, state}) {
      setInterval(() => {
        commit('increment')
        console.log(state.count)
      }, 1000)
    },
  },
})

new Vue({
  store, // 加入这一行
  render(h) {
    return h(App)
  },
}).$mount('#app')
